import request from '@/utils/axios'

export function getConfig(params) {
    return request({
        url: '/data/config',
        method: 'get',
        params
    })
}
// 查询所有的视频
export function queryVideos(params) {
    return request({
        url: '/video/all',
        method: 'get',
        params
    })
}
// 查询我的学习任务
export function selfTaskVideo() {
    return request({
        url: '/task/self',
        method: 'get'
    })
}
// 查询某人的学习情况
export function otherTask(params) {
    return request({
        url: '/task/other',
        method: 'get',
        params
    })
}
// 查询热门视频
export function queryHotVideos(top) {
    return request({
        url: `/video/hit/${top}`,
        method: 'get'
    })
}
// 查询试卷模板
export function queryPaperTemplates(params) {
    return request({
        url: '/template/query',
        method: 'get',
        params
    })
}
// 新增试卷模板
export function savePaperTemplate(data) {
    return request({
        url: '/template/save',
        method: 'post',
        data
    })
}
// 修改试卷模板
export function editPaperTemplate(data) {
    return request({
        url: '/template/edit',
        method: 'put',
        data
    })
}
// 删除试卷模板
export function deletePaperTemplate(templateId) {
    return request({
        url: `/template/delete/${templateId}`,
        method: 'delete'
    })
}
// 解析配置参数
export function parseConfig(config, param) {
    var codeName = ''
    config.forEach(item => {
        if (item.codeValue === param) {
            codeName = item.codeName
        }
    })
    return codeName
}
// 生成试卷
export function generatePaperSystem(params) {
    return request({
        url: '/paper/generator',
        method: 'post',
        params
    })
}
// 根据试卷编号生成练习
export function generatePracticeSystem(paperId) {
    return request({
        url: `/practice/generator/${paperId}`,
        method: 'get'
    })
}
// 查询最近试卷实例
export function queryRecentPractice(top) {
    return request({
        url: `/practice/recent/${top}`,
        method: 'get'
    })
}
// 查看练习详情
export function queryPracticeInfo(paperInstId) {
    return request({
        url: `/practice/show/${paperInstId}`,
        method: 'get'
    })
}
// 提交用户答案
export function parseUserAnswer(data) {
    return request({
        url: '/practice/correct',
        method: 'post',
        data
    })
}
// 查询学习记录
export function queryVideoLog(params) {
    return request({
        url: '/video/log',
        method: 'get',
        params
    })
}
// 删除学习记录
export function deleteVideoLog(logId) {
    return request({
        url: `/video/log/${logId}`,
        method: 'delete'
    })
}
// 修改视频观看记录，通过文件编号以及用户编号确定一条唯一的视频记录
export function updateVideoLog(data) {
    return request({
        url: '/video/log/adaptor',
        method: 'post',
        data
    })
}
// 上传视频
export function uploadVideo(formData) {
    return request({
        headers: {"Content-Type": "multipart/form-data;charset=utf-8"},
        url: '/video/upload',
        method: 'post',
        data: formData
    })
}
// 删除视频
export function deleteVideo(videoId) {
    return request({
        url: `/video/delete/${videoId}`,
        method: 'delete'
    })
}
// 查询所有题库信息
export function queryBanks(params) {
    return request({
        url: '/bank/query',
        method: 'get',
        params
    })
}
// 题库分析
export function bankAnalysis() {
    return request({
        url: '/bank/analysis',
        method: 'get'
    })
}
// 删除题库
export function deleteBank(bankId) {
    return request({
        url: `/bank/delete/${bankId}`,
        method: 'delete'
    })
}
// 修改题库
export function editBank(data) {
    return request({
        url: '/bank/edit',
        method: 'put',
        data
    })
}
// 保存题库
export function saveBank(data) {
    return request({
        url: '/bank/add',
        method: 'post',
        data
    })
}
// 查询题库详情
export function showBankInfo(params) {
    return request({
        url: '/problem/show',
        method: 'get',
        params
    })
}
// 新增试题
export function saveProblem(data) {
    return request({
        url: '/problem/save',
        method: 'post',
        data
    })
}
// 修改试题
export function editProblem(data) {
    return request({
        url: '/problem/edit',
        method: 'put',
        data
    })
}
// 删除试题
export function deleteProblem(problemId) {
    return request({
        url: `/problem/delete/${problemId}`,
        method: 'delete'
    })
}
// 新增答案
export function saveAnswer(data) {
    return request({
        url: '/answer/save',
        method: 'post',
        data
    })
}
// 查询问题答案
export function queryProblemAnswers(problemId) {
    return request({
        url: `/answer/${problemId}`,
        method: 'get'
    })
}
// 修改答案
export function editAnswer(data) {
    return request({
        url: '/answer/edit',
        method: 'put',
        data
    })
}
// 删除答案
export function deleteAnswer(answerId) {
    return request({
        url: `/answer/delete/${answerId}`,
        method: 'delete'
    })
}
// 增加视频点击量
export function videoHitAdd(videoId) {
    return request({
        url: `/video/hit/up/${videoId}`,
        method: 'get'
    })
}
// 给视频评分
export function videoAppraise(params) {
    return request({
        url: '/video/appraise',
        method: 'get',
        params
    })
}
// 查询当前视频阅读记录
export function queryCurrentVideoLog(fileId) {
    return request({
        url: `/video/log/current/${fileId}`,
        method: 'get'
    })
}
// 获取当前用户权限
export function getAuthorities() {
    return request({
        url: '/account/auth',
        method: 'get'
    })
}
// 查询所有的权限
export function queryAuthorities(params) {
    return request({
        url: '/auth/all',
        method: 'get',
        params
    })
}
// 修改权限
export function editAuthority(data) {
    return request({
        url: '/auth/edit',
        method: 'put',
        data
    })
}
// 删除权限
export function deleteAuthority(authorityId) {
    return request({
        url: `/auth/delete/${authorityId}`,
        method: 'delete',
    })
}
// 新增权限
export function saveAuthority(data) {
    return request({
        url: '/auth/save',
        method: 'post',
        data
    })
}
// 查询父级权限
export function queryParentAuthorities() {
    return request({
        url: '/auth/parent',
        method: 'get'
    })
}
// 查询所有的角色
export function queryRoles(params) {
    return request({
        url: '/role/query',
        method: 'get',
        params
    })
}
// 修改角色
export function editRole(data) {
    return request({
        url: '/role/edit',
        method: 'put',
        data
    })
}
// 删除角色
export function deleteRole(roleId) {
    return request({
        url: `/role/delete/${roleId}`,
        method: 'delete'
    })
}
// 新增角色
export function saveRole(data) {
    return request({
        url: '/role/save',
        method: 'post',
        data
    })
}
// 为角色授权
export function grantToRole(data) {
    return request({
        url: '/grant/role',
        method: 'post',
        data
    })
}
// 为用户授予角色
export function grantToUser(data) {
    return request({
        url: '/grant/account',
        method: 'post',
        data
    })
}
// 查询角色权限
export function queryRoleAuthorities(roleId) {
    return request({
        url: `/role/query/${roleId}`,
        method: 'get'
    })
}
// 查询所有权限不用条件
export function queryAuthoritiesNoCond() {
    return request({
        url: '/auth/no/cond',
        method: 'get'
    })
}
// 查询所有用户
export function queryAccounts(params) {
    return request({
        url: '/account/all',
        method: 'get',
        params
    })
}
// 查询当前用户角色
export function queryAccountRoles(accountId) {
    return request({
        url: `/account/roles/${accountId}`,
        method: 'get'
    })
}
// 查询试卷
export function queryPapers(params) {
    return request({
        url: '/paper/query',
        method: 'get',
        params
    })
}
// 修改试卷
export function editPaper(data) {
    return request({
        url: '/paper/edit',
        method: 'put',
        data
    })
}
// 删除试卷
export function deletePaper(paperId) {
    return request({
        url: `/practice/delete/paper/${paperId}`,
        method: 'delete'
    })
}
// 查看练习
export function queryPaperPractice(paperId) {
    return request({
        url: `/practice/query/${paperId}`,
        method: 'get'
    })
}
// 导出试卷
export function exportPaper(paperInstId) {
    return request({
        url: `/export/paper/${paperInstId}`,
        method: 'get'
    })
}
// 删除练习
export function deletePractice(paperInstId) {
    return request({
        url: `/practice/delete/${paperInstId}`,
        method: 'delete'
    })
}